package assdraw.model.test;

import assdraw.event.DrawingEvent;
import assdraw.event.DrawingListener;


public class ListenerSpy implements DrawingListener{

	private int[] count;
	
	/**
	 * Creates new instance
	 */
	public ListenerSpy(){
		count = new int[6];
	}
	
	@Override
	public void update(DrawingEvent e) {
		count[e.getKind()]++;
	}
	
	/**
	 * Gets number of accumulated RECTANGLE_ADDED drawing events
	 * @return number of RECTANGLE_ADDED drawing events
	 */
	public int getCountAdded(){
		return count[0];
	}
	/**
	 * Gets number of accumulated RECTANGLE_MOVED drawing events
	 * @return number of RECTANGLE_MOVED drawing events
	 */	
	public int getCountMoved(){
		return count[1];
	}	
	/**
	 * Gets number of accumulated RECTANGLE_SELECTION drawing events
	 * @return number of RECTANGLE_SELECTION drawing events
	 */
	public int getCountSelected(){
		return count[2];
	}
	/**
	 * Gets number of accumulated RECTANGLE_REMOVED drawing events
	 * @return number of RECTANGLE_REMOVED drawing events
	 */
	public int getCountRemoved(){
		return count[3];
	}
	/**
	 * Resets the counter
	 */
	public void reset(){
		for(int i=0; i<count.length; i++)
			count[i] = 0;
	}

}
